#!/usr/bin/env python3
"""调试params_map_kvpairs函数"""

import sys
import os
sys.path.append('doc/chainmaker-sdk-python-master')

from chainmaker.utils.common import params_map_kvpairs

def test_params_conversion():
    """测试参数转换"""
    print("测试params_map_kvpairs函数...")
    
    # 测试字典参数
    params = {'key': 'test_key', 'value': 'test_value'}
    print(f"输入参数: {params}")
    print(f"参数类型: {type(params)}")
    
    try:
        result = params_map_kvpairs(params)
        print(f"转换结果: {result}")
        print(f"结果类型: {type(result)}")
        
        if result:
            print(f"结果长度: {len(result)}")
            for i, item in enumerate(result):
                print(f"第{i+1}个元素: {item}, 类型: {type(item)}")
                if hasattr(item, 'key') and hasattr(item, 'value'):
                    print(f"  key: {item.key}, value: {item.value}")
    except Exception as e:
        print(f"转换失败: {e}")
        import traceback
        traceback.print_exc()

if __name__ == '__main__':
    test_params_conversion()